package com.example.shadingjdbc.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.shadingjdbc.entity.SysUser;
import com.example.shadingjdbc.mapper.UserMapper;
import com.example.shadingjdbc.service.UserService;
import org.springframework.stereotype.Service;

/**
 *
 */
@DS("slave")
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, SysUser> implements UserService {

    @Override
    public void insertUser(SysUser user) {
        this.save(user);
    }

    @Override
    public SysUser getDataByUsername(String username) {
        QueryWrapper<SysUser> wrapper = new QueryWrapper<SysUser>();
        wrapper.eq("user_name", username);
        return this.getOne(wrapper);
    }

    @Override
    public boolean save(SysUser entity) {
        return super.save(entity);
    }
}
